<?php
class DB {
	
	var $result;
	var $row;
	var $query;
	var $debug;
    var $nbrow;
	
	function DB($user="root",$pass="",$debug=TRUE){
		$this->debug=$debug;
		$this->host = "localhost";
		$this->db ="jypbook";
		$this->user = $user;
		$this->pass = $pass;
		$this->link = mysql_connect($this->host, $this->user, $this->pass);
		mysql_select_db($this->db);
	}
   
	function query($query) {
		if (!$this->result = mysql_query($query, $this->link))  {
			if ($this->debug) {
				echo mysql_error()."<br />".$query;
				echo "<hr />";
			}
		}
		return $this->result;
	}

	function getrownumber() {
		$this->nbrow=mysql_num_rows($this->result);
		return $this->nbrow;
	}
      
	   	
	function fetch() {
		$this->row=mysql_fetch_row($this->result);
		return $this->row;
	}
      
	function fetch_assoc() {
		$this->row=mysql_fetch_assoc($this->result);
		return $this->row;
	}
   
	function field_name($field_offset) {
		return mysql_field_name($this->result,$field_offset);
	}
	
	function insert_id() {
		return mysql_insert_id($this->link);
	}
}
?>
